
#include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<string>
#include <algorithm>
#include <dlfcn.h> 

#include "Singleton.h"


using namespace std;

typedef int (*WOB_MAP)(void); 



int test(const char* path, const char* funname)
{
	 void* lh = dlopen(path, RTLD_LAZY); 
	 if (NULL == lh)
	 {
		 printf("dlopen err\n");
		 return -1;
	 }

	 //singleton::instance();

	 dlerror();
	 char *error;
	 WOB_MAP process = (WOB_MAP)dlsym(lh, funname);
	 error = dlerror();
	 if (error)
	 {   
		 printf("dlsym map failed,error[%s]\n", error);                                                
		 return -1;                                                                         
	 }

	 process();

	 printf("afterso, k[%d]\n\n", singleton::instance()->return_int());

	 dlclose(lh);

	 return 0;
}

int main(int argc, char** argv)
{
	test(argv[1], "testso2");

	printf("-------------\n\n");

	test(argv[1], "testso");

	return 0;
}


